package com.example.vueadmin.mapper;

import com.example.vueadmin.entity.GoodSearch;
import com.example.vueadmin.entity.Goods;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface GoodsMapper {
    List<Goods> selectGoodsList(GoodSearch goodSearch);

    Integer total(GoodSearch goodSearch);

    @Insert("INSERT into `goods` (goods_id,goods_name,category_id,keyword,create_time,cost,unit,price,quality) VALUES (#{goodsId},#{goodsName},#{categoryId},#{keyword},#{createTime},#{cost},#{unit},#{price},#{quality})")
    Integer addGoods(Goods goods);

    @Delete("DELETE from `goods` where goods_id = #{id}")
    Integer delete(Integer id);

    Integer deleteAll(Integer[] ids);

    @Update("UPDATE `goods`set goods_name=#{goodsName},category_id=#{categoryId},keyword=#{keyword},update_time=#{updateTime},unit=#{unit},price=#{price},cost=#{cost},quality=#{quality} where goods_id = #{goodsId}")
    Integer updateGoods(Goods goods);
}
